package edu.ensmp.ckEditor.main;

import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

import edu.ensmp.ckEditor.util.Constants;


public class Logger {

	private StringBuffer sb;

	public Logger() {
		sb = new StringBuffer(300);
	}

	public void addLine(String line) {
		sb.append(line + Constants.newline);
		System.out.println(toString());
	}

	public void SaveToFile(String fileName) throws FileNotFoundException,
			IOException {
		Writer output = new BufferedWriter(new FileWriter(fileName));
		try {
			output.write(sb.toString());
		} finally {
			output.close();
		}
	}

	public String toString() {
		return sb.toString();
	}

}
